<template>

  <div id="formContainer">
    <a-tree
        :data="treeData"
    />
  </div>

</template>

<script>
import axios from 'axios';

const treeData = [
  {
    title: '根节点',
    key: '0',
    children: [],
  },
];
export default {
  data() {
    return {
      treeData,
    }
  }, methods: {
    listChildren: (node, holdData) => {
      let url = '/dm/list';
      if (process.env.NODE_ENV === 'development') {
        url = window.dev.httpUrlBase + url;
      }
      axios.get(url, {
        node: node
      }).then((res) => {
        holdData(res.data);
      }).catch((err) => {
        console.log(err);
        return null;
      })
    }, parseTreeNode(data) {
      return {
        title:data.displayName,
        key : data.sn
      }
    }
  },

  created() {
    this.listChildren('0', (data) => {
      this.treeData[0].children = [];
      for (let i = 0; i < data.length; i++) {
        this.treeData[0].children.push(this.parseTreeNode(data[i]));
      }
    })
  }
}
</script>
<style>
#formContainer {
  border-right: 1px solid var(--color-border);
  width: 60%;
}
</style>